<template>
  <div>
    <!-- 头部导航栏 -->
    <head-component :title="name"/>
    <div class="zilaio_box">
      <div v-html="text"></div>
    </div>
  </div>
</template>
<script>
import headComponent from '@/components/layout/head'
export default {
  name: '',
  components: {
    headComponent
  },
  data() {
    return {
      name: this.$route.query.name,
      id: this.$route.query.id,
      text: ''
    }
  },
  watch: {},
  mounted() {
    this.getNews()
  },
  methods: {
    getNews(){
      var $this = this;
      var t = this.$toast.loading({message: '正在加载数据', mask: true, duration: 9999})
      var data = {u_id: localStorage.getItem('uid'), token: localStorage.getItem('token')};
      $this.$axios.post('index.php?m=index&c=consult', data)
        .then((res) => {
          t.clear();
          if (res.data.code == 1) {
            res.data.news.map((item, index) => {
              if(item.id == $this.id){
                $this.text = item.news_content;
              }
            })
          } else {
            $this.$router.push('/login');
          }
        });

    }
  },
}
</script>
<style lang="less">
  .zilaio_box{
    margin-top: 1.2rem;
    border-top: 0.02rem solid #f5f5f5;
    padding: 0.4rem 0.6rem;
  }
</style>
